
$(function(){
	// 头部固定栏 
	$(window).scroll(function(){
		
		if($(window).scrollTop() < 110){
			$('#header-fixed').animate({top:-70},30)
		}else if($(window).scrollTop() >= 110){
			$('#header-fixed').animate({top:0},30)
		}
	})
	$('#header-fixed #all-List').hover(function(){
		$('#all-List-nav').show()
		$('#all-List-nav #all-List-mume').show()
		$('.all-List-icon').addClass('all-List-icon-active')
	},function(){
		$('#all-List-nav #all-List-mume').hide()
		$('.all-List-icon').removeClass('all-List-icon-active')
	})
	$('#all-List-nav').hover(function(){
		$('#all-List-nav #all-List-mume').show()
		$('.all-List-icon').addClass('all-List-icon-active')
		
	},function(){
		$('#all-List-nav #all-List-mume').hide()
		$('.all-List-icon').removeClass('all-List-icon-active')
		$('#all-List-nav #all-List-container').hide()
	})
	//  hover
	$('#all-List-nav #all-List-mume dd').each(function(index){
		$(this).hover(function(){
			$('#all-List-nav #all-List-mume dd').removeClass('haderNav-Active').find('a').removeClass('haderNav-aActive')
			$(this).addClass('haderNav-Active')
			$(this).find('a').addClass('haderNav-aActive')
			$('#all-List-nav #all-List-container').show()
			$('#all-List-content div').hide()
			$('#all-List-content div').eq(index).show().hover(function(){
				$('#all-List-content div').hide()
			    $('#all-List-content div').eq(index).show()
			    $('#all-List-nav #all-List-mume dd').eq(index).addClass('haderNav-Active')
			    $('#all-List-nav #all-List-mume dd').eq(index).find('a').addClass('haderNav-aActive')
			})
			
		},function(){
			$(this).removeClass('haderNav-Active')
			$(this).find('a').removeClass('haderNav-aActive')
			$('#all-List-content div').eq(index).hide()
		})
	})
	$('#all-List-container-close').click(function(){
		$('#all-List-nav').hide()
		$('#all-List-nav #all-List-mume dd').removeClass('haderNav-Active')
		$('#all-List-nav #all-List-mume dd a').removeClass('haderNav-aActive')
	})
	
	// 头部导航栏  左栏
	$('#haderNav #haderNav-left span').hover(function(){
		$('#haderNav #haderNav-left dl').show()
		$(this).addClass('haderNav-left-spanActive')
	},function(){
		$('#haderNav #haderNav-left dl').hide()
		$(this).removeClass('haderNav-left-spanActive')
	})
	$('#haderNav #haderNav-left dl').hover(function(){
		$(this).show()
		$('#haderNav #haderNav-left span').addClass('haderNav-left-spanActive')
	},function(){
		$(this).hide()
		$('#haderNav #haderNav-left span').removeClass('haderNav-left-spanActive')
	})
	$('#haderNav #haderNav-left dl dd').each(function(index){
		$(this).hover(function(){
			$('#haderNav #haderNav-left dl dd').removeClass('haderNav-left-ddActive')
			$(this).addClass('haderNav-left-ddActive')
		},function(){
			$(this).removeClass('haderNav-left-ddActive')
		})
	})
	// 头部导航栏  右栏
	$('#haderNav-right dl').each(function(index){
		$(this).hover(function(){
			if(index == 3){
				$('#counts-box').show()
			}
			$(this).find('dt a').addClass('haderNav-right-aActive')
			$(this).find('dd').show().css('background',webkitSpeechRecognitionError)
			$(this).removeClass('haderNav-left-spanActive')
			$(this).addClass('haderNav-left-spanActive')
		},function(){
			if(index == 3){
				$('#counts-box').hide()
			}
			$(this).removeClass('haderNav-left-spanActive')
			$(this).find('dd').hide()
			$(this).find('dt a').removeClass('haderNav-right-aActive')
		})
	})
	
	//banner-Okcard
	$('#banner-Okcard').hover(function(){
		$(this).addClass('Okcard')
		$(this).find('a').addClass('OkcardA')
	},function(){
		$(this).removeClass('Okcard')
		$(this).find('a').removeClass('OkcardA')
	})
	
	//banner-Nav
	$('#bannerNav ul li a').each(function(index){
		$(this).hover(function(){
			$(this).addClass('aActive')
		},function(){
			$(this).removeClass('aActive')
		})
		$(this).click(function(){
			$('#bannerNav ul li a').removeClass('aclick')
			$(this).addClass('aclick')
		})
	})
	$('#header-AD-close').click(function(){
		$('#header-AD').hide()
	})
	
	// banner-body banner-body-list 所有商品列表
	$('#banner-body-list #banner-body-list-mume dl dd').each(function(index){
		$(this).hover(function(){
			$('#banner-body-list #banner-body-list-mume dl dd').removeClass('banner-list-Active')
			$('#banner-body-list #banner-body-list-mume dl dd').find('a').removeClass('banner-list-aActive')
			$(this).addClass('banner-list-Active')
			$(this).find('a').addClass('banner-list-aActive')
			$('#banner-body-list #banner-body-list-container').show()
			$('#banner-body-list #banner-body-list-container #banner-body-list-content div').fadeOut(30)
			$('#banner-body-list #banner-body-list-container #banner-body-list-content div').eq(index).fadeIn(100).hover(function(){
				$('#banner-body-list #banner-body-list-mume dl dd').removeClass('banner-list-Active')
			    $('#banner-body-list #banner-body-list-mume dl dd').find('a').removeClass('banner-list-aActive')
				$('#banner-body-list #banner-body-list-container').show()
				$('#banner-body-list #banner-body-list-mume dl dd').eq(index).addClass('banner-list-Active')
			    $('#banner-body-list #banner-body-list-mume dl dd').eq(index).find('a').addClass('banner-list-aActive')
			},function(){
				$('#banner-body-list #banner-body-list-container').hide()
				$('#banner-body-list #banner-body-list-mume dl dd').removeClass('banner-list-Active')
			    $('#banner-body-list #banner-body-list-mume dl dd').find('a').removeClass('banner-list-aActive')
			})
				
		},function(){
			$(this).removeClass('banner-list-Active')
			$(this).find('a').removeClass('banner-list-aActive')
			$('#banner-body-list #banner-body-list-container').hide()
		})
		$('#banner-body-list-container-close').click(function(){
			$('#banner-body-list #banner-body-list-container').hide()
			$('#banner-body-list #banner-body-list-mume dl dd').removeClass('banner-list-Active')
			$('#banner-body-list #banner-body-list-mume dl dd').find('a').removeClass('banner-list-aActive')
		})
	    $('#banner-body-list-AD').hover(function(){
	   	   $('#banner-body-list #banner-body-list-container').show()
	    },function(){
	   	    $('#banner-body-list #banner-body-list-container').hide()
	    })
	})
	
	//   banner-body-timer   轮播图
	var n = -1;
	var timer = 0;
	startMove()
	
	function startMove(){
		n++;
		if(n==$('#banner-body-timer ul li').length){
			n = 0;
		}
		$('#banner-body-timer ul li').hide().eq(n).show()
		$('#banner-body-timer #pic-index .pic-index-box dd').animate({width:15}).removeClass('ddIndexActive')
		$('#banner-body-timer #pic-index .pic-index-box dd').eq(n).animate({width:30}).addClass('ddIndexActive')
	}
	
	timer = window.setInterval(startMove,3000)
	
	$('#banner-body-timer #pic-index .pic-index-box dd').each(function(index){
		$(this).hover(function(){
			window.clearInterval(timer)
			$('#picUp').animate({left:240},100)
			$('#picNext').animate({right:239},100)
			$('#banner-body-timer ul li').hide().eq(index).show()
			$('#banner-body-timer #pic-index .pic-index-box dd').animate({width:15},50).removeClass('ddIndexActive')
		    $(this).animate({width:30},50).addClass('ddIndexActive')
		},function(){
			n = index;
			timer = window.setInterval(startMove,3000)
		})
		
	})
	$('#banner-body-timer ul li').hover(function(){
		window.clearInterval(timer)
		$('#picUp').animate({left:240},100)
		$('#picNext').animate({right:239},100)
	},function(){
		timer = window.setInterval(startMove,3000)
		$('#picUp').animate({left:200},100)
		$('#picNext').animate({right:199},100)
	})
	$('#picUp').hover(function(){
		$(this).addClass('picUp-enter').animate({left:240},100)
	},function(){
		$(this).removeClass('picUp-enter')
	})
	$('#picNext').hover(function(){
		$(this).addClass('picUp-enter').animate({right:239},100)
	},function(){
		$(this).removeClass('picUp-enter')
	})
    
    
    // channel 特色频道
    $('#channel img').each(function(index){
    	$(this).hover(function(){
    		$(this).css('border','1px solid crimson')
    	},function(){
    		$(this).css('border','none')
    	})
    })

    //  floor
    
    var i = -1;
	var floorSlidetimer = 0;
	floorSlide()
	
	function floorSlide(){
		i++;
		if(i==3){
			i = 0;
		}
		$('.floor-slide').each(function(){
			$(this).find('li').hide().eq(i).show()
			$(this).find('dd').animate({width:20}).removeClass('floor-slide-active')
			$(this).find('dd').eq(i).animate({width:30}).addClass('floor-slide-active')
		})
			
	}
	floorSlidetimer = window.setInterval(floorSlide,4000)
	
	var $nav = $('#floor-index');
	var $floor = $('.floor');
	$(window).on('scroll',function(){
		var scrollTop = $(window).scrollTop();
		
		var floorindex = Math.floor((scrollTop-1050)/475);
		if (scrollTop > 1050) {
			$nav.fadeIn('slow');
	        if(floorindex >= $floor.length-1 ){
	        	floorindex = 7;
	        }
	       $nav.find('li').not('.last').removeClass('hover').eq(floorindex).addClass('hover');
		} else {
			$nav.fadeOut('fast');
		}
	})
	$nav.on('click','li',function(){
		var index = $(this).index();
		var top;
		if($(this).hasClass('last')){
			top = 0;
		}else{
			top = $floor.eq(index).offset().top + index*20;
		}
		$('html,body').animate({scrollTop:top});
	});
	//获取购物车商品数量
	window.setTimeout(function(){
		$('.cart_num').html(JSON.parse($.cookie('Car')).length)
	},2000)
})